﻿<!--#include file="../inc/common.asp" -->
<%
    response.AddHeader "Last-Modified", DateToGMT(Now())
    response.Expires = 0
    response.CacheControl = "no-cache"
  
    if not userObj.isAdmin then
        response.write "您没有权限"
        call closeDB()
        response.end
    end if    
    call OpenDB
%>
<HTML><HEAD><TITLE><%=hostTitle%></TITLE>
<META http-equiv=Content-Type content="text/html; charset=<%=DEFAULT_CHARSET%>">
<style type="text/css">
li {
	line-height: 200%;
	}
</style>	
</HEAD>
<BODY>
<div align=center>
<%    
    dim  blog_id, blog_title, blog_desc, user_id, user_name
    
    if request("submit")=" 创建 " then
        user_name = request("user_name")
        blog_title = request("blog_title")
        blog_desc = request("blog_desc")
        
        dim tmpUserObj
        set tmpUserObj = new UserClass
        tmpUserObj.load(user_name)
        if not tmpUserObj.isFound then
            response.write(user_name & "不存在")
        else
            user_id=tmpUserObj.userId
            
            sql = " select * from blog where blog_id<>1 and user_id=" & user_id
            rs.open sql, conn, 1, 3
            if not rs.eof and request("new")<>"true" then
                response.write(user_name & "已经拥有blog，id="&rs("blog_id"))
            else
                rs.addNew()
                rs("blog_title")=blog_title
                rs("blog_desc")=blog_desc
                rs("user_id")=user_id
                rs("user_name")=user_name
                rs("photo_url")="photo/t1.gif"
                rs("page_size")=6
                rs.update()

                conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 1, '管理员', '管理员', true, true, true, true, true, true) ")
                conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 2, '好友', '好友', true, true, true, true, false, false) ")
                conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 3, '注册网友', '注册网友', true, true, false, false, false, false) ")
                conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 4, '匿名网友', '匿名网友', true, true, false, false, false, false) ")
                conn.execute(" insert into blog_user_group(blog_id, group_id, group_name, group_desc, can_read, can_reply, can_post, can_read_secret, can_delete,  can_manage) values (" & rs("blog_id") &", 5, '黑名单', '黑名单', false, false, false, false, false, false) ")

                dim mlHost
                set mlHost = new MLHostClass   
                mlHost.reload()                  

                response.write(user_name & "开通了blog，<a href='../index.asp?blog_id=" & rs("blog_id") & "' target='_blank'>id=" & rs("blog_id") & "</a>")
                
            
            end if
            rs.close()

            
        end if
        set tmpUserObj = nothing
        
    end if    
        
%>

<form name=form1 method=post>

<p>blog标题:<input type=text name="blog_title" value=""></p>
<p>blog描述:<input type=text name="blog_desc" size=50 value=""></p>
<p>用户名:<input type=text name="user_name" value=""></p>
<p><input type=checkbox name="new" value="true">该用户可以拥有多个BLOG<br>
<p><input type=submit name="submit" value=" 创建 "></p>
</form>

<a href="index.asp">返回</a>

</div>
</BODY>
</HTML>

<!--#include file="../inc/end.asp" -->